/**
 * Author: Shen Yanqiu
 * Date: 2018-02-26
 * Time: 15:59
 *
 */
import React from 'react';
import { Page } from 'components';
import TopOperation from 'components/TopOperation';
import { connect } from 'dva';
import { Table, Row, Col } from 'antd';
import PropTypes from 'prop-types';
import styles from './style.less';
import TopRightButton from "../../../components/TopOperation/TopRightButton";

const settings = {
  designation: true, // 名称输入框
  status: false, // 状态选择框
  ownership: false, // 所属选择框
  section: true, // 部门选择框
  starlevel: false, // 星级选择框
  object: false, // 对象选择框
  time: false, // 时间选择框
}

class RecruitnewStatisticsPersonDetails extends React.Component {
  static propTypes = {
    loading: PropTypes.object,
    recruitnewStatisticsPersonDetails: PropTypes.object,
    dispatch: PropTypes.func,
  };
  render() {
    const { loading, recruitnewStatisticsPersonDetails, dispatch } = this.props;
    const { list, pagination } = recruitnewStatisticsPersonDetails;
    const SearchData = (data) => {
      dispatch({
        type: 'recruitnewStatisticsPersonDetails/searchData',
        payload: {
          formData: data,
        },
      });
    };
    const _getColumnConfig = () => {
      return [{
        title: '名称',
        dataIndex: 'username',
        key: 'username',
      }, {
        title: '部门',
        dataIndex: 'department',
        key: 'department',
      }, {
        title: '联系方式',
        dataIndex: 'contactWay',
        key: 'contactWay',
      }, {
        title: '性别',
        dataIndex: 'sex',
        key: 'sex',
        render: (text, record) => <span>{text === 0 ? "男" : "女"}</span>
      }];
    };
    const tableProps = {
      loading: loading.effects['recruitnewStatisticsPersonDetails/loadTableList'],
      columns: _getColumnConfig(),
      dataSource: list,
      pagination,
      rowKey: r => r.id,
      onChange (_pagination) {
        dispatch({
          type: 'recruitnewStatisticsPersonDetails/loadTableList',
          payload: {
            current: _pagination.current,
            pageSize: _pagination.pageSize,
          },
        });
      },
    };
    const exportData = () => {
      dispatch({
        type: 'recruitnewStatisticsPersonDetails/exportData',
      });
    };
    return (
      <Page loading={loading.effects['recruitnewStatisticsPersonDetails/firstLoad']}>
        <TopOperation {...settings} SearchData={SearchData} />
        <Row className={styles.recruitnewStatisticsPersonDetails}>
          <Col>
            <Table
              {...tableProps}
            />
          </Col>
        </Row>
        <TopRightButton contentText={"导出数据"} clickHandle={exportData} />
      </Page>
    );
  }
}
export default connect(({ loading, recruitnewStatisticsPersonDetails }) => ({ loading, recruitnewStatisticsPersonDetails }))(RecruitnewStatisticsPersonDetails);
